<?php
/**
 * <https://y.st./>
 * Copyright © 2017 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => 'tryme3.py',
	'<{subtitle}>' => 'Written in <span title="Programming Fundamentals">CS 1101</span> of <a href="http://www.uopeople.edu/">University of the People</a>, finalised on 2017-02-22',
	'<{copyright year}>' => '2017',
	'takedown' => '2017-11-01',
	'<{body}>' => <<<END
<h2>Script:</h2>
<blockquote>
<pre><code># Every good program should begin with a license comment that declares the file
# as being covered by a free software license.
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program. If not, see &lt;https://www.gnu.org./licenses/&gt;.

# Prints one blank line
#
# The version of the function new_line() in the instructions looks like this:
#
## def new_line():
##         print()
#
# However, that version of the function doesn&apos;t work in Python2. In Python2, it
# doesn&apos;t print blank lines. Instead, it prints the string representation of
# empty tuples. That&apos;s obviously now what we want. So, I took out the
# parentheses and made the function look like this:
#
## def new_line():
##         print
#
# Success! It now worked in Python2! So what was the problem? Well, it now no
# longer worked in Python3! If I recall, &quot;print&quot; is a keyword in Python2, but a
# function in Python3. In Python, functions are objects, and we all know that
# objects are a type of variable. (In Python, all variables are objects, but
# that&apos;s not the point. The point is that all functions are variables in
# Python.) With out the parentheses, it was no longer a function call, but
# simply an expression without an assignment! I ended up settling on the
# implementation below, which works in both Python2 and Python3.
def new_line():
	print(&quot;&quot;)

# Prints three blank lines
def three_lines():
	new_line()
	new_line()
	new_line()

# Prints nine blank lines
def nine_lines():
	three_lines()
	three_lines()
	three_lines()

# Prints twenty-five blank lines
# ( 9 + 9 + 3 + 3 + 1 == 25 )
def clear_screen():
	nine_lines()
	nine_lines()
	three_lines()
	three_lines()
	new_line()

# The assignment instructions say to define both nine_lines() and
# clear_screen(), but only says to actually call clear_screen(). In theory,
# this script should call clear_screen() but should avoid calling nine_lines().
# However, the instructions also say to put separators between the output of the
# functions. That seems to heavily imply that both functions get called. The
# assignment also doesn&apos;t explicitly say *not* to call both functions, so I&apos;m
# calling them both to be safe and hope that that&apos;s okay.
#
# This next part is pretty much documented by the calls to print(), so I&apos;m done
# commenting now. I would live to have put a print statement after the call to
# clear_screen() to contain the blank lines between visible lines, but the
# instructions specifically state that the call to clear_screen() should be on
# the final line.
#
# Oh wait, now that I think about it, it&apos;ll be contained by the prompt that
# shows up after the script completes.

print(&quot;now printing 9 lines&quot;)
nine_lines()

print(&quot;now printing 25 lines&quot;)
clear_screen()</code></pre>
</blockquote>
<h2>Output:</h2>
<blockquote>
<pre>Python 2.7.9 (default, Jun 29 2016, 13:08:31) 
[GCC 4.9.2] on linux2
Type &quot;copyright&quot;, &quot;credits&quot; or &quot;license()&quot; for more information.
&gt;&gt;&gt; ================================ RESTART ================================
&gt;&gt;&gt; 
now printing 9 lines









now printing 25 lines

























&gt;&gt;&gt;</pre>
</blockquote>
END
);
